#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int m, n;
    scanf("%d %d", &m, &n);
    int a[10][10];
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int t;
            scanf("%d", &t);
            a[i][j] = t;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            printf("%d ", a[j][i]);
        }
        printf("\n");
    }
    return 0;
}